import request from "../axios";

/**
 * 退出登录
 * @returns 
 */
export function adminExit() {
    return request({
        method: "GET",
        url: '/user/logout'
    })
}

//商品图片上传
export function UploadFile(data) {
    return request({
        method: "Post",
        url: '/employeeProfile/updateEmployeeImg',
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        data: data,
    })
}

//新增员工档案信息
export function addEmployeeProfile(data) {
    return request({
        method: "Post",
        url: '/employeeProfile/addEmployeeProfile',
        data: data,
    })
}

/**
 * 分页查询档案信息
 * @param {*} page 当前页
 * @param {*} size 每页大小
 * @returns 
 */
export function selectEmployeeProfileByAdmin(page, size) {
    return request({
        method: "POST",
        url: "/employeeProfile/selectEmployeeProfileByAdmin",
        params: {
            page: page,
            size: size
        },
    })
}

/**
 * 分页查询审核中，未通过的档案信息
 * @param {*} page 当前页
 * @param {*} size 每页大小
 * @param {*} type 状态，1为审核中，2为通过，3为未通过
 * @returns 
 */
export function selectEmployeeProfileByState(page, size, type) {
    return request({
        method: "POST",
        url: "/employeeProfile/selectEmployeeProfileByState",
        params: {
            page: page,
            size: size,
            type: type
        },
    })
}

/**
 * 通过id删除档案用户信息
 * @param {*} id 用户id
 * @returns 
 */
export function deleteEmployeeProfileById(id) {
    return request({
        method: "POST",
        url: '/employeeProfile/deleteEmployeeProfileById',
        params: {
            id: id
        }
    })
}

/**
 * 管理修改档案用户信息（或者申请修改）
 * @param {*} data 用户信息
 * @returns 
 */
export function updateEmployeeProfile(data) {
    return request({
        method: "Post",
        url: '/employeeProfile/updateEmployeeProfile',
        data: data,
    })
}

/**
 * 管理员审核档案用户信息
 * @param {*} id 用户id
 * @param {*} state 审核状态
 * @returns 
 */
export function updateEmployeeUpdateStatus(id, state) {
    return request({
        method: "Post",
        url: '/employeeProfile/updateEmployeeUpdateStatus',
        params: {
            id: id,
            state: state
        }
    })
}

/**
 * 通过id查询档案用户信息
 * @param {*} userId 用户id
 * @returns 
 */
export function selectEmployeeProfileById(userId) {
    return request({
        method: "POST",
        url: '/employeeProfile/selectEmployeeProfileById',
        params: {
            userId: userId
        }
    })
}

/**
 * 通过模糊查询档案用户信息
 * @param {*} userId 用户id
 * @returns 
 */
export function selectEmployeeProfileByName(name) {
    return request({
        method: "POST",
        url: '/employeeProfile/selectEmployeeProfileByName',
        params: {
            name: name
        }
    })
}


/**
 * 通过档案审核状态模糊查询档案用户信息
 * @param {*} userId 用户id
 * @returns 
 */
export function selectEmployeeProfileByStateLike(name, ExamineType) {
    return request({
        method: "POST",
        url: '/employeeProfile/selectEmployeeProfileByStateLike',
        params: {
            name: name,
            type: ExamineType
        }
    })
}

/**
 * 查询所有客户信息， 管理员可查询所有， 业务员只能查询自己的
 * @param {*} userId 用户id
 * @returns 
 */
export function selectAllClients(page, size, address, type) {
    return request({
        method: "POST",
        url: '/clients/selectAllClients',
        params: {
            page: page,
            size: size,
            address: address,
            type: type
        }
    })
}


/**
 * 新增客户信息
 *
 * @returns 
 */
export function insertClients(data) {
    return request({
        method: "POST",
        url: '/clients/insertClients',
        data: data
    })
}


/**
 * 修改客户信息
 *
 * @returns 
 */
export function updateClients(data) {
    return request({
        method: "POST",
        url: '/clients/updateClients',
        data: data
    })
}


/**
 * 通过客户id查询客户信息
 * @param {*} id 用户id
 * @returns 
 */
export function selectClientsById(id) {
    return request({
        method: "POST",
        url: '/clients/selectClientsById',
        params: {
            id: id
        }
    })
}


/**
 * 通过id查询客户交流记录
 * @param {*} id 用户id
 * @returns 
 */
export function selectChatByClientId(id) {
    return request({
        method: "POST",
        url: '/clients/selectChatByClientId',
        params: {
            id: id
        }
    })
}



/**
 * 通过id删除客户信息
 * @param {*} id 用户id
 * @returns 
 */
export function deleteClientsById(id) {
    return request({
        method: "POST",
        url: '/clients/deleteClientsById',
        params: {
            id: id
        }
    })
}

/**
 * 继续添加交流记录
 */
export function insertChat(data) {
    return request({
        method: "POST",
        url: '/clients/insertChat',
        data: data
    })
}

/**
 * 通过id审核客户信息，修改状态
 * @returns id 用户id type 审核状态
 */
export function auditClients(id, type) {
    return request({
        method: "POST",
        url: '/clients/auditClients',
        params: {
            id: id,
            type: type
        }
    })
}

/**
 * 通过搜索条件查询客户信息
 */
export function selectClientsBySearch(name) {
    return request({
        method: "POST",
        url: '/clients/selectClientsBySearch',
        params: {
            name: name
        }
    })
}

/**
 * 查询包括已删除的客户
 */
export function getClientWithDelete(data) {
	return request({
		method: "POST",
		url: '/clients/getClientWithDelete',
		data: data
	})
}

/**
 * 查询所有业务员
 */
export function adminGetSalesman() {
    return request({
        method: "POST",
        url: '/user/adminGetSalesman',
    })
}


/**
 * 客户分配给业务员
 */
export function dispatchClients(ids, userId) {
    return request({
        method: "POST",
        url: '/clients/dispatchClients',
        params: {
            ids: ids,
            userId: userId
        }
    })
}


/**
 * 业务员查询排行榜邀请客户数量
 */
export function selectClientsCountByType(typeOne, typeTwo) {
    return request({
        method: "POST",
        url: '/clients/selectClientsCountByType',
        params: {
            typeOne: typeOne,
            typeTwo: typeTwo
        }
    })
}

/**
 * 新增产品信息
 */
export function apply(data) {
    return request({
        method: "POST",
        url: '/products/apply',
        data: data
    })
}

/**
 * 申请入库
 */
export function purchaseReceiptsApply(data) {
    return request({
        method: "POST",
        url: '/purchaseReceipts/apply',
        data: data
    })
}

/**
 * 库管审核入库
 * receiptsId: 入库单id
 * receiptsStatus: 审核状态
 */
export function adminCheck(receiptsId, receiptsStatus) {
    return request({
        method: "POST",
        url: '/purchaseReceipts/adminCheck',
        params: {
            receiptsId: receiptsId,
            receiptsStatus: receiptsStatus
        }
    })
}


/**
 * 查询供应商列表
 */
export function suppliersList() {
    return request({
        method: "POST",
        url: '/suppliers/list',
    })
}


/**
 * 新增供应商信息
 */
export function suppliersAdd(data) {
    return request({
        method: "POST",
        url: '/suppliers/add',
        data: data
    })
}


/**
 * 查询采购订单列表
 */
export function purchaseList() {
    return request({
        method: "POST",
        url: '/purchaseReceipts/purchaseList',
    })
}

/**
 * 根据名称查询仓库已有的产品
 */
export function selectName(name) {
    return request({
        method: "POST",
        url: '/devices/selectName',
        params: {
            name: name
        }
    })
}


/**
 * 员工查询申请采购订单信息， 分页查询
 *
 * @returns 
 */
export function purchaseInfoList(page, size) {
    return request({
        method: "POST",
        url: '/products/purchaseInfoList',
        params: {
            page: page,
            size: size,
        }
    })
}


/**
 * 员工查询入库订单信息， 分页查询
 *
 * @returns 
 */
export function purchaseReceiptsInfoList(page, size, receiptsStatus) {
    return request({
        method: "POST",
        url: '/products/purchaseReceiptsInfoList',
        params: {
            page: page,
            size: size,
            receiptsStatus: receiptsStatus
        }
    })
}


/**
 * 员工查询申请采购订单信息， 分页查询
 *
 * @returns 
 */
export function purchaseReceiptsInfo(receiptsId) {
    return request({
        method: "POST",
        url: '/purchaseReceipts/purchaseReceiptsInfo',
        params: {
            receiptsId: receiptsId,
        }
    })
}


/**
 * 管理查询仓库产品信息， 分页查询
 *
 * @returns 
 */
export function devicesSelectList(page, size, status) {
    return request({
        method: "POST",
        url: '/devices/selectList',
        params: {
            page: page,
            size: size,
            status: status
        }
    })
}


/**
 * 用户出库申请
 *
 * @returns 
 */
export function applyOutbound(data) {
    return request({
        method: "POST",
        url: '/devicesOutbound/applyOutbound',
        data: data
    })
}

/**
 * 管理审核出库
 * devicesOutboundId: 出库单id
 * status: 审核状态
 * @returns 
 */
export function adminCheckOutbound(devicesOutboundId, status) {
    return request({
        method: "POST",
        url: '/devicesOutbound/adminCheckOutbound',
        params: {
            devicesOutboundId: devicesOutboundId,
            status: status
        }
    })
}


/**
 * 管理查询仓库产品信息， 分页查询
 *
 * @returns 
 */
export function devicesOutboundSelectList(page, size, status) {
    return request({
        method: "POST",
        url: '/devicesOutbound/selectList',
        params: {
            page: page,
            size: size,
            status: status
        }
    })
}


/**
 * 管理查询仓库产品信息， 分页查询
 *
 * @returns 
 */
export function DevOutselectById(devicesOutboundId) {
    return request({
        method: "POST",
        url: '/devicesOutbound/selectById',
        params: {
            devicesOutboundId: devicesOutboundId
        }
    })
}


/**
 * 用户归还设备申请
 *
 * @returns 
 */
export function devReturn(data) {
    return request({
        method: "POST",
        url: '/devicesOutbound/devReturn',
        data: data
    })
}


/**
 * 查询当前用户借出设备
 *
 * @returns 
 */
export function UserSelectList() {
    return request({
        method: "POST",
        url: '/devicesReturn/UserSelectList',
    })
}


/**
 * 查询当前用户借出设备
 *
 * @returns 
 */
export function selectPageList(page, size, status) {
    return request({
        method: "POST",
        url: '/devicesReturn/selectPageList',
        params: {
            page: page,
            size: size,
            status: status
        }
    })
}

/**
 * 管理审核归还
 *
 * @returns 
 */
export function adminCheckReturn(returnId, status) {
    return request({
        method: "POST",
        url: '/devicesReturn/adminCheckReturn',
        params: {
            returnId: returnId,
            status: status
        }
    })
}


/**
 * 管理通过入库id查询入库信息
 *
 * @returns 
 */
export function selectReturnById(returnId) {
    return request({
        method: "POST",
        url: '/devicesReturn/selectReturnById',
        params: {
            returnId: returnId,
        }
    })
}




/**
 * 查询搜索模糊查询采购记录
 *
 * @returns 
 */
export function purchaseInfo(name) {
    return request({
        method: "POST",
        url: '/products/purchaseInfo',
        params: {
            name: name,
        }
    })
}

/**
 * 查询搜索模糊查询采购记录
 *
 * @returns 
 */
export function selectLikeName(name) {
    return request({
        method: "POST",
        url: '/devicesReturn/selectLikeName',
        params: {
            name: name,
        }
    })
}


/**
 * 查询搜索模糊查询入库管理订单
 *
 * @returns 
 */
export function purchaseReceiptsInfos(name) {
    return request({
        method: "POST",
        url: '/products/purchaseReceiptsInfos',
        params: {
            name: name,
        }
    })
}


/**
 * 查询搜索模糊查询仓库库存产品
 *
 * @returns 
 */
export function devicesSelectLike(name) {
    return request({
        method: "POST",
        url: '/devices/selectLike',
        params: {
            name: name,
        }
    })
}


/**
 * 查询搜索模糊查询仓库零件信息
 *
 * @returns 
 */
export function selectPartLike(name) {
    return request({
        method: "POST",
        url: '/devices/selectPartLike',
        params: {
            name: name,
        }
    })
}


/**
 * 管理员给产品添加配件
 *
 * @returns 
 */
export function addProductPart(data) {
    return request({
        method: "POST",
        url: '/productPart/addProductPart',
        data: data
    })
}

/**
 * 通过id查询成品配件
 *
 * @returns 
 */
export function ProductPartId(ProductPartId) {
    return request({
        method: "POST",
        url: '/productPart/ProductPartId',
        params: {
            ProductPartId: ProductPartId,
        }
    })
}


/**
 * 根据产品id查询产品所需配件是否充足， 以及百分比显示,和最多能生产多少产品
 *
 * @returns 
 */
export function selectProductPartList(ProductPartId) {
    return request({
        method: "POST",
        url: '/productPart/selectProductPartList',
        params: {
            ProductPartId: ProductPartId,
        }
    })
}



/**
 * 查询仓库所有配件
 *
 * @returns 
 */
export function selectPartList() {
    return request({
        method: "POST",
        url: '/devices/selectPartList',
    })
}

/**
 * 采购产品一键入库
 *
 * @returns 
 */
export function applyInbound(productIds) {
    return request({
        method: "POST",
        url: '/purchaseReceipts/applyInbound',
        params: {
            productIds: productIds,
        }
    })
}

/**
 * 新增产品到仓库,而不是零件
 *
 * @returns 
 */
export function addProductIs(data) {
    return request({
        method: "POST",
        url: '/devices/addProductIs',
        data: data
    })
}

/**
 * 查询百分比
 *
 * @returns 
 */
export function selectPercent() {
    return request({
        method: "POST",
        url: '/devices/selectPercent',
    })
}

/**
 * 修改百分比
 *
 * @returns 
 */
export function updatePercent(percent) {
    return request({
        method: "POST",
        url: '/devices/updatePercent',
        params: {
            percent: percent,
        }

    })
}

/**
 * 管理修改入库记录表
 */
export function updateReceiptsInfo(data) {
    return request({
        method: "POST",
        url: '/products/updateReceiptsInfo',
        data: data
    })
}


/**
 * 管理修改仓库产品信息
 */
export function adminUpdateDevice(data) {
    return request({
        method: "POST",
        url: '/devices/adminUpdateDevice',
        data: data
    })
}


/**
 * 查询当前用户借出设备
 *
 * @returns 
 */
export function selectOutboundList(page, size) {
    return request({
        method: "POST",
        url: '/devices/selectOutboundList',
        params: {
            page: page,
            size: size,
        }
    })
}

/**
 * 查询当前用户借出设备
 *
 * @returns 
 */
export function selectOutboundLike(name) {
    return request({
        method: "POST",
        url: '/devices/selectOutboundLike',
        params: {
            name: name,
        }
    })
}

/**
 * 通过用户id给用户评分, 不能给自己评分
 *
 * @returns 
 */
export function addUserScore(userId, score) {
    return request({
        method: "POST",
        url: '/userScore/addUserScore',
        params: {
            userId: userId,
            score: score,
        }
    })
}

/**
 * 给自己添加工作记录
 *
 * @returns 
 */
export function addWorkSummary(data) {
    return request({
        method: "POST",
        url: '/workSum/addWorkSummary',
        data: data
    })
}

/**
 * 查询工作列表
 *
 * @returns 
 */
export function selectWorkSummaryList() {
    return request({
        method: "POST",
        url: '/workSum/selectWorkSummaryList',
    })
}


/**
 * 查询指定天数类的总分数排名
 *
 * @returns 
 */
export function selectUserScoreList(day) {
    return request({
        method: "POST",
        url: '/userScore/selectUserScoreList',
        params: {
            day: day,
        }
    })
}


/**
 * 查询当前售后人员的派单记录, 分页
 *
 * @returns 
 */
export function afterDispatch(page, size) {
    return request({
        method: "POST",
        url: '/afterSales/afterDispatch',
        params: {
            page: page,
            size: size,
        }
    })
}


/**
 * 查询当前售后人员的派单记录, 分页
 *
 * @returns 
 */
export function selectExchange(afterSalesId) {
    return request({
        method: "POST",
        url: '/afterRecords/selectExchange',
        params: {
            afterSalesId: afterSalesId,
        }
    })
}


/**
 * 通过派单id添加交流记录
 *
 * @returns 
 */
export function addExchange(data) {
    return request({
        method: "POST",
        url: '/afterRecords/addExchange',
        data: data
    })
}

/**修改保存派单的安装时间和培训内容
 * @returns 
 */
export function updateInstall(data) {
    return request({
        method: "POST",
        url: '/afterSales/updateInstall',
        data: data
    })
}

/**管理查询所有用户审核员信息
 * @returns 
 */
export function examineList() {
    return request({
        method: "POST",
        url: '/examine/examineList',
    })
}

/**管理查询所有用户审核员信息
 * @returns 
 */
export function examineUpdate(data) {
    return request({
        method: "POST",
        url: '/examine/examineUpdate',
        data: data
    })
}

/**管理查询所有用户审核员信息
 * @returns 
 */
export function examineByType(type) {
    return request({
        method: "POST",
        url: '/examine/examineByType',
        params: {
            type: type,
        }
    })
}

/**厂长审核采购信息
 * @returns 
 */
export function applyCheck(receiptsId, status) {
    return request({
        method: "POST",
        url: '/purchaseReceipts/applyCheck',
        params: {
            receiptsId: receiptsId,
            status: status,
        }
    })
}


/**厂长查询审核信息
 * @returns 
 */
export function selectCheck(page, size) {
    return request({
        method: "POST",
        url: '/selectCheck/selectCheck',
        params: {
            page: page,
            size: size,
        }
    })
}


/** 管理查询报销记录
 * @returns 
 */
export function expenseList() {
    return request({
        method: "POST",
        url: '/expense/expenseList'
    })
}

/** 员工添加报销记录
 * @returns 
 */
export function addExpense(price, info) {
    return request({
        method: "POST",
        url: '/expense/addExpense',
        params: {
            price: price,
            info: info
        }
    })
}


/** 管理审核报销记录
 * @returns 
 */
export function expenseUpdate(id, status) {
    return request({
        method: "POST",
        url: '/expense/expenseUpdate',
        params: {
            id: id,
            status: status
        }
    })
}

/**
 * 查询支出记录
 */
export function paymentPurchaseList(page, size, type) {
    return request({
        method: "POST",
        url: '/payment/purchaseList',
        params: {
            page: page,
            size: size,
            type: type
        }
    })
}


/**
 * 查询供应商总支出
 */
export function paymentPurchaseReceiptsInfoList(type) {
    return request({
        method: "POST",
        url: '/payment/purchaseReceiptsInfoList',
        params: {
            type: type
        }
    })
}

export function getGoodsCategory(params) {
    return request({
        method: "POST",
        url: '/dieBonus/getGoodsCategory',
		data: params
    })
}